/**
 * Created with Intellij IDEA.
 * Description;
 * User:墨琦
 * Data:2023-03-23
 * Time:19:30
 */
public class Tclone {
    public static void main(String[] args) throws CloneNotSupportedException {
        Text11 fw=new Text11("汤琦",20);
        Text11 fw1=(Text11)fw.clone();
        System.out.println(fw1.age);
        fw1.w.sex="女";
        System.out.println("拷贝前的文件："+fw.w.sex);
        System.out.println("拷贝后的文件："+fw1.w.sex);

    }

}
class A implements Cloneable{
    String sex;
    A(String a)
    {
        sex=a;
    }
    protected A clone() throws CloneNotSupportedException{
        A fw=(A)super.clone();
        return fw;
    }
}

class Text11 implements Cloneable{
     String name;
     int age;
     A w=new A("男");
  Text11(String name,int age)
  {
      this.age=age;
      this.name=name;
  }
  protected Text11 clone() throws CloneNotSupportedException {
      Text11 kk=(Text11)super.clone();
      kk.w=(A)w.clone();
      return kk;
  }
}